package com.ellricky.baselib.ui.order.complain

import com.ellricky.baselib.R
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.entity.new.ComplainRecord
import com.ellricky.baselib.http.HttpUtils
import com.ellricky.baselib.ui.base.BaseDetailActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.baselib.util.NewEntityCallback
import kotlinx.android.synthetic.main.pd_activity_complain_detail.*

class ComplainDetailActivity : BaseDetailActivity() {

    override fun getChildContentLayout(): Int {
        return R.layout.pd_activity_complain_detail
    }

    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.pd_complain_detail)
        loadDetail(id)
    }

    private fun loadDetail(id: String) {
        val url = EAppUtil.getApiHost()
        val paramMap = mutableMapOf(
            "action" to "complainDetail",
            "complain_id" to id,
            "eid" to LocalCacheUtil.getUid()
        )

        HttpUtils.getInstance()
            .postFrom(url, paramMap, object : NewEntityCallback<ComplainRecord>(this) {

                override fun onSuccess(data: ComplainRecord, msg: String) {
                    tvComplainPerson.text = data.complain_name
                    tvBackTelDesc.text = data.complain_tel
                    tvComplainContent.text = data.complain_desc
                }
            }, this)
    }
}
